//
//  OderCell.m
//  
//
//  Created by chris on 15/12/26.
//
//

#import "OderCell.h"

@implementation OderCell

- (void)awakeFromNib {
    // Initialization code
}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self)
    {
        self.backgroundColor = [UIColor clearColor];
        
        UIImageView * bgIV = [[UIImageView alloc]initWithFrame:CGRectMake(10, 0, DEF_SCREEN_WIDTH-20, 120*ratio_heigth)];
        bgIV.backgroundColor = [UIColor whiteColor];
        bgIV.layer.cornerRadius = 5.0;
        bgIV.layer.masksToBounds = YES;
        [self.contentView addSubview:bgIV];
        
        NSArray * titles = @[@"工单号：",@"工单类型：",@"工单状态：",@"创建时间：",@"创建门店："];
        for (int i = 0; i < 5; i++)
        {
            UILabel * titleLa = [[UILabel alloc]initWithFrame:CGRectMake1(10, 15+(5+15)*i,65, 15)];
//            titleLa.backgroundColor = [UIColor redColor];
            if (i == 0)
            {
                titleLa.textColor = [UIColor colorWithRed:0.13 green:0.06 blue:0.6 alpha:1];
            }
            else
            {
                titleLa.textColor = [UIColor lightGrayColor];
            }
            titleLa.font = font(13);
            titleLa.text = titles[i];
            [bgIV addSubview:titleLa];
            
            UILabel * contentLa = [[UILabel alloc]initWithFrame:CGRectMake1(75, 15+(5+15)*i, DEF_SCREEN_WIDTH-105, 15)];
//            contentLa.backgroundColor = [UIColor lightGrayColor];
            if (i == 0)
            {
                contentLa.textColor = [UIColor colorWithRed:0.13 green:0.06 blue:0.6 alpha:1];
            }
            else
            {
                contentLa.textColor = [UIColor blackColor];
            }
            contentLa.font = font(13);
            switch (i)
            {
                case 0:
                    _orderNumLa = contentLa;
                    break;
                case 1:
                    _typeLa = contentLa;
                    break;
                case 2:
                    _statusLa = contentLa;
                    break;
                case 3:
                    _dateLa = contentLa;
                    break;
                case 4:
                    _storeLa = contentLa;
                    break;
                default:
                    break;
            }
            [bgIV addSubview:contentLa];
        }
    }
    return self;
}

CG_INLINE CGRect
CGRectMake1(CGFloat x, CGFloat y, CGFloat width, CGFloat height)
{
    CGRect rect;
    rect.origin.x = x*ratio_width; rect.origin.y = y*ratio_heigth;
    rect.size.width = width*ratio_width; rect.size.height = height*ratio_heigth;
    return rect;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
